package com.ruoyi.web.controller.trade;

import com.github.pagehelper.PageInfo;
import com.hundun.vision.api.dto.ProfitDTO;
import com.hundun.vision.api.query.ProfitQuery;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.service.ProfitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：RuoChen
 * @date ：20:24 2021/3/2
 * @description：收益控制器
 */
@RestController
@RequestMapping("/trade/profit")
public class ProfitController extends BaseController {

    @Autowired
    private ProfitService profitService;

    @PreAuthorize("@ss.hasPermi('trade:profit:search')")
    @GetMapping("/search")
    public TableDataInfo search(ProfitQuery query) {
        PageInfo<ProfitDTO> pageInfo = profitService.search(query);
        return getDataTable(pageInfo);
    }

    @PreAuthorize("@ss.hasPermi('trade:profit:trades')")
    @GetMapping(value = "/trades/{robotId}")
    public TableDataInfo trades(@PathVariable Long robotId) {
        return getDataTable(profitService.getTrades(robotId));
    }
}
